<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Lightweight OS (LWOS): sample.c File Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Lightweight OS (LWOS)
   
   </div>
   <div id="projectbrief">A diminutive operating system</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a> &#124;
<a href="#var-members">Variables</a>  </div>
  <div class="headertitle">
<div class="title">sample.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Simple example of LWOS features.  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;stdio.h&gt;</code><br/>
<code>#include &quot;<a class="el" href="lwos_8h_source.html">lwos.h</a>&quot;</code><br/>
<code>#include &lt;stdlib.h&gt;</code><br/>
<code>#include &lt;time.h&gt;</code><br/>
</div><table class="memberdecls">
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sample_8c.html#a867ab10c10761b09791e2c540e162392">task0</a> (<a class="el" href="lwos_8h.html#af41b315a18a5782b8182db98ab85c5b7">Task</a> *tcb)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sample_8c.html#a4cb8ffd2cf8ec2be24a98b3069008aba">task1</a> (<a class="el" href="lwos_8h.html#af41b315a18a5782b8182db98ab85c5b7">Task</a> *tcb)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sample_8c.html#aedbe1fdb28af1a8adf42f31d165024fa">task2</a> (<a class="el" href="lwos_8h.html#af41b315a18a5782b8182db98ab85c5b7">Task</a> *tcb)</td></tr>
<tr><td colspan="2"><h2><a name="var-members"></a>
Variables</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">TASKWAIT_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sample_8c.html#a03718ea498f637d6055cd4d7984c9a39">task1lock</a> = 0</td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Simple example of LWOS features. </p>
<dl class="author"><dt><b>Author:</b></dt><dd>Al Williams </dd></dl>
<dl class="date"><dt><b>Date:</b></dt><dd>30 Oct 2012 To build: gcc -g -o sample <a class="el" href="sample_8c.html" title="Simple example of LWOS features.">sample.c</a> <a class="el" href="lwos_8c.html" title="Main library source for LWOS.">lwos.c</a> </dd></dl>
</div><hr/><h2>Function Documentation</h2>
<a class="anchor" id="a867ab10c10761b09791e2c540e162392"></a><!-- doxytag: member="sample.c::task0" ref="a867ab10c10761b09791e2c540e162392" args="(Task *tcb)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="sample_8c.html#a867ab10c10761b09791e2c540e162392">task0</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="lwos_8h.html#af41b315a18a5782b8182db98ab85c5b7">Task</a> *&#160;</td>
          <td class="paramname"><em>tcb</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>This is a user task that updates the <em>task_tick</em> used for sleeping. Note that whatever task updates the tick can't use timer wait In this case, the tick is simply a 1 second count </p>

</div>
</div>
<a class="anchor" id="a4cb8ffd2cf8ec2be24a98b3069008aba"></a><!-- doxytag: member="sample.c::task1" ref="a4cb8ffd2cf8ec2be24a98b3069008aba" args="(Task *tcb)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="sample_8c.html#a4cb8ffd2cf8ec2be24a98b3069008aba">task1</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="lwos_8h.html#af41b315a18a5782b8182db98ab85c5b7">Task</a> *&#160;</td>
          <td class="paramname"><em>tcb</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>A simple task that prints something 10 times and then blocks </p>

</div>
</div>
<a class="anchor" id="aedbe1fdb28af1a8adf42f31d165024fa"></a><!-- doxytag: member="sample.c::task2" ref="aedbe1fdb28af1a8adf42f31d165024fa" args="(Task *tcb)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="sample_8c.html#aedbe1fdb28af1a8adf42f31d165024fa">task2</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="lwos_8h.html#af41b315a18a5782b8182db98ab85c5b7">Task</a> *&#160;</td>
          <td class="paramname"><em>tcb</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>A simple task that prints once per second It also wakes up task 1 periodically </p>

</div>
</div>
<hr/><h2>Variable Documentation</h2>
<a class="anchor" id="a03718ea498f637d6055cd4d7984c9a39"></a><!-- doxytag: member="sample.c::task1lock" ref="a03718ea498f637d6055cd4d7984c9a39" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">TASKWAIT_t <a class="el" href="sample_8c.html#a03718ea498f637d6055cd4d7984c9a39">task1lock</a> = 0</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>This is a wait variable (like a semaphore) The idea is that task1 will go as fast as possible for 10 times and then wait on the semaphore Then task2 will run once per second for 10 seconds and unlock the wait variable </p>

</div>
</div>
</div><!-- contents -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Mon Nov 19 2012 22:30:11 for Lightweight OS (LWOS) by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.6.1
</small></address>

</body>
</html>
